<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    
</body>
<script>
    function makeIterator(array){
        var nextIndex = 0;
        return {
            next:function(){
                return nextIndex < array.length ?{ value: array[nextIndex++],done: false } : { value: undefined, done: true };
            }
        };
    }

    var obj = makeIterator([2,8,4,6,5]);
    console.log(obj);

    var result = obj.next();
    console.log(result);

    var result = obj.next();
    console.log(result);

    var result = obj.next();
    console.log(result);

    var result = obj.next();
    console.log(result);

    var result = obj.next();
    console.log(result);

    var result = obj.next();
    console.log(result);
</script>
</html>